/*
struct ListNode {
    int val;
    struct ListNode *next;
    ListNode(int x) :
        val(x), next(NULL) {
    }
};
*/
class Solution {
public:
    ListNode* deleteDuplication(ListNode* head) {
       //创建一个虚拟头节点
        ListNode* virhead=(ListNode*)malloc(sizeof(ListNode));
        virhead->val=-1;
        virhead->next=head;
        //cur是工作指针，表示当前指针是否可以被连接
        auto cur=virhead;
        auto pre=virhead;
        //virhead->1->1->2->2->3
        while(cur)
        {
            while(cur->next&&cur->val==cur->next->val)
                cur=cur->next;
            cur=cur->next;
            if(cur&&cur->next&&cur->next->val==cur->val)
                continue;
            pre->next=cur;
            pre=pre->next;
        }
        return virhead->next;
    }
};